package com.np.adapter;

import java.util.List;

import com.np.dto.ThuChi;
import com.np.moneylover.R;


import android.R.color;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;




public class ThuChiAdapter extends ArrayAdapter<ThuChi>{
	  
    
    private Activity context;
	private int layout;
	private List<ThuChi>list;
	public ThuChiAdapter(Context context, int textViewResourceId,
			List<ThuChi> objects) {
		super(context, textViewResourceId, objects);
		// TODO Auto-generated constructor stub
		this.context=(Activity) context;
		this.layout=textViewResourceId;
		this.list=objects;
	}
	
    @Override
    public int getCount() {
        return list.size();
    }
     
    @Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		LayoutInflater flater=context.getLayoutInflater();
		View row=flater.inflate(layout, parent,false);
		TextView txt1=(TextView) row.findViewById(R.id.lbtengiaodich);
		TextView txt2=(TextView) row.findViewById(R.id.lbsotiengiaodich);
		///TextView txt3=(TextView) row.findViewById(R.id.viewmotalm);
		
		ThuChi data=list.get(position);
		txt1.setText(data.getTenGD());
		if(data.getMaGD()==1)
		{
		   txt2.setText(data.getSoTien().toString());
		}
		if(data.getMaGD()==2)
			
		{
			/*txt2.setBackgroundColor(Color.RED);
			txt2.setTextColor(color.white);*/
			String tien="-"+ data.getSoTien().toString();
			txt2.setText(tien);
		
		}
			
			
		
		
		//if(position==0)
		//{
		//	row.setBackgroundColor(Color.RED);
		//}
		return row;
	}
}


